package com.gwc.schedule.service.impl;

import com.gwc.schedule.dao.SysUserDao;
import com.gwc.schedule.dao.impl.SysUserDaoImpl;
import com.gwc.schedule.pojo.SysUser;
import com.gwc.schedule.service.SysUserService;
import com.gwc.schedule.util.MD5Util;

import java.util.List;

public class SysUserServiceImpl implements SysUserService {
    private SysUserDao sysUserDao = new SysUserDaoImpl();
    public int regist(SysUser user) {
        // 在这里将用户密码转换为密文的
        user.setUserPwd(MD5Util.encrypt(user.getUserPwd()));
        // 调用Dao层方法将user信息存入数据库中
        return sysUserDao.addSysUser(user);
    }

    @Override
    public SysUser findByUsername(String username) {
        List<SysUser> sysUserList = sysUserDao.findByUsername(username);
        return sysUserList!=null && sysUserList.size()>0? sysUserList.get(0):null ;
    }
}
